/*
This file is part of IRCaBot.
IRCaBot is IRC logger with features.
Source code: https://notabug.org/acetone/ircabot.
Copyright (C) acetone, 2023.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <QObject>
#include <QTcpServer>
#include <QThreadPool>

constexpr const char HTTP_URI_VOICEGATE_PREFIX[] = "voicegate.php";
constexpr const char HTTP_URI_VOICEGATE_ACTION_INVITE[] = "invite";
constexpr const char HTTP_URI_VOICEGATE_ACTION_CHECK[] = "check";
constexpr const char HTTP_URI_VOICEGATE_ACTION_BAD_CAPTCHA[] = "badcaptcha";
constexpr const char HTTP_URI_VOICEGATE_ACTION_TIMEOUT[] = "timeout";

constexpr const char HTTP_URI_STATIC_PREFIX[] = "static";
constexpr const char HTTP_URI_STATIC_EMBEDDED_PREFIX[] = "static.php";

constexpr const char HTTP_URI_MAIN_PREFIX[] = "index.php";
constexpr const char HTTP_URI_CHATLOG_PREFIX[] = "history.php";
constexpr const char HTTP_URI_CHATLOG_PARAM_NETWORK[] = "n";
constexpr const char HTTP_URI_CHATLOG_PARAM_CHANNEL[] = "c";
constexpr const char HTTP_URI_CHATLOG_PARAM_YEAR[] = "y";
constexpr const char HTTP_URI_CHATLOG_PARAM_MONTH[] = "m";
constexpr const char HTTP_URI_CHATLOG_PARAM_DAY[] = "d";

class HttpServer : public QTcpServer
{
    Q_OBJECT
public:
    HttpServer(QObject* parent = nullptr);
    ~HttpServer();
    void stop();

signals:
    void doStopPrivate();

private slots:
    void stopPrivate();

protected:
    void incomingConnection(qintptr handle);

private:
    QThreadPool *m_pool;
};

